package com.wootion.cims.module.landing.login.controller;

import com.wootion.cims.module.landing.login.service.LoginService;
import com.wootion.cims.module.systemsetting.user.model.User;
import com.wootion.cims.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: jack
 * @Date: 2022/12/02/13:33
 * @Description:
 */
@RestController
@RequestMapping(path = {"/user"})
@Api(value = "用户登陆")
public class LoginController {

    @Resource
    private LoginService loginService;
    
    /**
     * 登陆
     */
    @PostMapping(path = {"/login"})
    @ApiOperation(value = "用户登陆", httpMethod = "POST", notes = "{\"username\":\"李四\",\"password\":\"123456\"}")
    public ResponseResult login(@RequestBody @Validated User user, HttpServletRequest request) throws UnsupportedEncodingException {
        return loginService.login(user,request);
    }

    @GetMapping(path = "/checked")
    @ApiOperation(value = "检查用户是否需要修改密码",httpMethod = "GET")
    public ResponseResult checked(){
        return loginService.checked();
    }
}
